//引入模块
const express = require('express');
//中间件cookie
const cookie = require('cookie-parser');
//body中间件
const bodyParser = require('body-parser');
//path模块
const path = require('path');

//创建express框架应用模块
const app = express();

//模板引擎设置
//__dirname  : D:\Node复习\员工管理数据库\员工管理平台   常量，当前项目路径   localhost：端口
app.set('views', path.join(__dirname , 'templates'));
app.set('view engine' , 'ejs');
//解析中间件
app.use(bodyParser.urlencoded({extended:false}));

app.use(bodyParser.json());   //对象字符串  应用body中间件
//console.log(bodyParser)
//console.log(cookie)

app.use(cookie());    //应用cookie中间件

const moment = require('moment');
app.locals.moment = moment;

//加载静态页面
app.use(express.json());

app.use(express.urlencoded({extended:false}));
app.use(express.static( path.join( __dirname , 'public') ));

//导入业务模块
const login = require('./routes/login');
const home = require('./routes/home');
const logout = require('./routes/logout');  //退出登录
const chenck = require('./routes/chenck');  //更改密码
const paylist = require('./routes/paylist');  //查看工资条
const selPermsg = require('./routes/sel_permsg');  //查询所有员工信息
const addPermsg = require('./routes/add_permsg');  //添加所有员工信息
const addLogin = require('./routes/add_login');  //添加员工登录账号等
const sleMsgpay = require('./routes/sle_msgpay');  //查询所有员工薪资
const addMsgpay = require('./routes/add_msgpay');  //添加员工薪资
const msgUpdate = require('./routes/msg_update');  //编辑员工信息
const delMsg = require('./routes/del_msg');  //删除员工信息
const eduUpdate = require('./routes/edu_update');  //制定学历薪资
const staUpdate = require('./routes/sta_update');  //制定员工薪资
const payUpdate = require('./routes/pay_update');  //修改员工工资条


//
app.use('/', login);
app.use('/home', home);
app.use('/logout', logout);
app.use('/chenck', chenck);
app.use('/paylist', paylist);
app.use('/sel_permsg', selPermsg);
app.use('/add_permsg', addPermsg);
app.use('/add_login', addLogin);
app.use('/sle_msgpay', sleMsgpay);
app.use('/add_msgpay', addMsgpay);
app.use('/msg_update', msgUpdate);
app.use('/del_msg', delMsg);
app.use('/edu_update', eduUpdate);
app.use('/sta_update', staUpdate);
app.use('/pay_update', payUpdate);


//开启监听
app.listen(8080 , ()=>{
    console.log('开启监听')
})